package main

import (
	"v8s-sm-proxy/internal/clients/v8s"
	"v8s-sm-proxy/internal/configuration"
	"v8s-sm-proxy/internal/dropapp"
	"v8s-sm-proxy/internal/handlers"
	gen_consolegw "v8s-sm-proxy/rest/target/generated-sources/consolegw"
	gen_devprofile "v8s-sm-proxy/rest/target/generated-sources/devprofile"
	"v8s/http-server"
	"v8s/logger"
)

func main() {
	properties := configuration.ReadProperties()
	logger.BuildLogger(properties.Log)

	v8sClient := v8s.NewClient(properties.V8S)
	manager := dropapp.NewManager(v8sClient, properties.V8S)

	handler := handlers.NewHandlers(manager)

	managementServer := server.NewServer(properties.ManagementServer, true)
	httpsServer := server.NewServer(properties.HttpsServer, false)

	gen_consolegw.RegisterHandlers(httpsServer, handler)
	gen_devprofile.RegisterHandlers(httpsServer, handler)

	errors := server.RunServers(managementServer, httpsServer)

	select {
	case err := <-errors:
		panic(err)
	}
}
